import { createRouter, createWebHashHistory } from 'vue-router'
// 路由规则步骤
// 1.按需加载路由组件（懒加载）
//  路由组件的按需加载（懒加载）
/* const Login = () => import('@/views/login/index.vue') */
const Layout = () => import('@/views/layout/index.vue')
const Home = () => import('@/views/home/index.vue')
// const Test = () => import('@/views/test/index.vue')
const Product = () => import('@/views/product/index.vue')
const routes = [
  // 2.主页面路由配置
  {
    path: '/',
    component: Layout,
    children: [
      // 3.主页二级路由配置
      { path: '/', component: Home },
      { path: '/product/:id', component: Product }
    ]
  }
  // 4.登录页面路由配置
  /* { path: '/login', component: Login } */
]

// 5. 创建路由实例
const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则，写法和之前一样
  routes //
})

export default router
